<!DOCTYPE html>
<html>

<head>
  <title>软件工程大作业</title>
  <meta http-equiv="content-type" content="txt/html; charset=utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
  <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>

<body class="container">

  <nav class="navbar navbar-default" role="navigation">
    <div class="container-fluid">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#example-navbar-collapse">
          <span class="sr-only">切换导航</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" id="wlcb" href="#">软件工程大作业</a>
      </div>
      <div class="collapse navbar-collapse" id="example-navbar-collapse">
        <ul class="nav navbar-nav">
          <li class="active"><a href="#" id="sys1b">进货子系统</a></li>
          <li><a href="#" id="sys2b">库存子系统</a></li>
          <li class="active"><a href="#" id="sys3b">销售子系统</a></li>
        </ul>
        <ul class="nav navbar-nav navbar-right">
          <li><a href="#" id="sys4b">后台管理</a></li>
        </ul>
      </div>
    </div>
  </nav>
  <div style="font-family:Microsoft YaHei">
    <div id="wlc">
      <h1>欢迎来到超市进销存管理信息系统</h1>
      <h3 style="text-align: right;">code by 贼大的桔子</h3>
    </div>
    <div id="sys1">
      <caption>商品验收处理</caption>
      <form class="form-horizontal" role="form">
        <div class="form-group">
          <label class="col-sm-1 control-label">传票编码:</label>
          <div class="col-sm-5">
            <input type="text" class="form-control" id="1" value=1000001 disabled>
          </div>
          <label class="col-sm-1 control-label">商品编码:</label>
          <div class="col-sm-5">
            <input type="text" class="form-control" id="2" value="100000" placeholder="6位数字">
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-1 control-label">商品名</label>
          <div class="col-sm-5">
            <input type="text" class="form-control" id="3" value="Tanmay" placeholder="商品名">
          </div>
          <label class="col-sm-1 control-label">规格：</label>
          <div class="col-sm-5">
            <input type="text" class="form-control" id="4" value="25kg" placeholder="规格">
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-1 control-label">厂商：</label>
          <div class="col-sm-5">
            <input type="text" class="form-control" id="5" value="浙江温州江南皮革厂" placeholder="厂商">
          </div>
          <label class="col-sm-1 control-label">有效期：</label>
          <div class="col-sm-5">
            <input type="text" class="form-control" id="6" value="12月" placeholder="有效期">
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-1 control-label">进价：</label>
          <div class="col-sm-5">
            <input type="text" class="form-control" id="7" value="35$" placeholder="进价">
          </div>
          <label for="8" class="col-sm-1 control-label">进货数量：</label>
          <div class="col-sm-5">
            <input type="text" class="form-control" id="8" value="100" placeholder="进货数量">
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-7">
            <button id="csjhcp" class="btn btn-default">产生进货传票</button>
            <button class="btn btn-default" onclick="alert('打印成功')">打印进货传票</button>

          </div>

        </div>
      </form>
      <hr class="simple" color="#ffffff" />
      <table class="table">
        <caption>进货传票列表</caption>
        <thead>
          <tr>
            <th>传票编码</th>
            <th>商品编码</th>
            <th>商品名</th>
            <th>规格</th>
            <th>厂商</th>
            <th>有效期</th>
            <th>进价</th>
            <th>进货数量</th>
          </tr>
        </thead>
        <tbody id="jhcdlb">
        </tbody>
      </table>
      <table class="table">
        <caption>商品目录</caption>
        <thead>
          <tr>
            <th>商品编码</th>
            <th>商品名</th>
            <th>规格</th>
            <th>厂商</th>
            <th>有效期</th>
            <th>销售价格</th>
          </tr>
        </thead>
        <tbody id='spml'>

        </tbody>
      </table>
    </div>
    <div id="sys2">
      <table class="table">
        <caption>库存账</caption>
        <thead>
          <tr>
            <th>商品编码</th>
            <th>商品名</th>
            <th>规格</th>
            <th>厂商</th>
            <th>有效期</th>
            <th>进货量</th>
            <th>出库量</th>
            <th>销售价格</th>
            <th>库存数量</th>
            <th>库存下限量</th>
            <th>库存上限量</th>
          </tr>
        </thead>
        <tbody id='kcz'>

        </tbody>
      </table>
    </div>

    <div id="sys3">
      <h3>定价处理：</h3>
      <table class="table">
        <caption>商品价格表</caption>
        <thead>
          <tr>
            <th>商品编码</th>
            <th>商品名</th>
            <th>规格</th>
            <th>厂商</th>
            <th>有效期</th>
            <th>建议价格</th>
            <th>销售价格</th>
            <th>批准责任人</th>
          </tr>
        </thead>
        <tbody id='spjgb'>
        </tbody>
      </table>
      <hr class="simple" color="#ffffff" />
      <form class="form-horizontal" role="form">
        <div class="form-group">
          <label class="col-sm-1 control-label">传票编码:</label>
          <div class="col-sm-5">
            <input type="text" class="form-control" id="11" value=1000001 disabled>
          </div>
          <label class="col-sm-1 control-label">商品编码:</label>
          <div class="col-sm-5">
            <input type="text" class="form-control" id="12" value="100000" placeholder="6位数字">
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-7">
            <button id="csxscp" class="btn btn-default">产生销售传票</button>
          </div>
          <button class="btn btn-default" onclick="alert('打印成功')">打印销售传票</button>

        </div>
      </form>
      <h3>销售处理：</h3>
      <table class="table">
        <caption>销售传票表</caption>
        <thead>
          <tr>
            <th>销售传票编码</th>
            <th>商品编码</th>
            <th>商品名</th>
            <th>规格</th>
            <th>厂商</th>
            <th>有效期</th>
            <th>销售价格</th>
            <th>销售数量</th>
          </tr>
        </thead>
        <tbody id='xscpb'>

        </tbody>
      </table>
    </div>
    <div id="sys4">
      <div>
        <h4>管理员修改商品价格</h4>
        <label for="21" class="col-sm-2 control-label">商品编码:</label>
        <div class="col-sm-4">
          <input type="text" class="form-control" id="21" value="100000">
        </div>
        <label for="22" class="col-sm-2 control-label">修改价格:</label>
        <div class="col-sm-4">
          <input type="text" class="form-control" id="22" value="36$">
        </div>
        <button class="btn btn-default" id="tjsq">提交申请</button>
      </div>
      <div style="height: 30px;margin-top: 90px;"></div>
      <div>
        <h4>经理审批</h4>
        <div id="jlsp">




        </div>
      </div>
    </div>

  </div>

  <script>
    $("#sys1").hide();
    $("#sys2").hide();
    $("#sys3").hide();
    $("#sys4").hide();
    $('#wlcb').click(function () {
      $('#wlc').show();
      $("#sys1").hide();
      $("#sys2").hide();
      $("#sys3").hide();
      $("#sys4").hide();
    })
    let jhcps = [];
    let spmls = [];
    $("#tjsq").click(function () {
      let spbm = $('#21').val();
      let id = -1;
      for (let i = 0; i < spmls.length; i++) {
        if (spmls[i] === spbm) {
          id = i;
        }
      }

      let value = parseInt($('#22').val());
      if (id != -1) $('#jlsp').append('<div class="alert alert-warning" id="' + id + '"><a href="#" class="close" data-dismiss="alert">&times;</a><strong>新提示！</strong>有个修改价格的需求需要您审批。将编码为' + spbm + '的商品价格更改为' + value + '         <button class="btn btn-default" onclick="change(' + id + ',' + value + ')">同意</button></div>');
    });
    function change(id, value) {

      $('#spml').find('tr').eq(id).find('th').eq(5).text(value + '$');
      $('#kcz').find('tr').eq(id).find('th').eq(7).text(value + '$');
      $('#' + id + '').alert('close');
    }
    $("#sys1b").click(function () {
      $('#wlc').hide();
      $("#sys1").show();
      $("#sys2").hide();
      $("#sys3").hide();
      $("#sys4").hide();
    })
    $("#sys2b").click(function () {
      $('#wlc').hide();
      $("#sys1").hide();
      $("#sys2").show();
      $("#sys3").hide();
      $("#sys4").hide();
    })
    $("#sys3b").click(function () {
      $('#wlc').hide();
      $("#sys1").hide()
      $("#sys2").hide();
      $("#sys3").show();
      $("#sys4").hide();
    })
    $("#sys4b").click(function () {
      $('#wlc').hide();
      $("#sys1").hide();
      $("#sys2").hide();
      $("#sys3").hide();
      $("#sys4").show();
    })
    //进货子系统
    //进货传票
    function jhcp(cpbm, spbm, pm, gg, cs, yxq, jj, jhsl) {
      this.cpbm = cpbm;
      this.spbm = spbm;
      this.pm = pm;
      this.gg = gg;
      this.cs = cs;
      this.yxq = yxq;
      this.jj = jj;
      this.jhsl = jhsl;
    }
    //1-8

    //产生销售传票
    $('#csxscp').click(function () {
      let id = $('#11').val();
      $('#11').val(parseInt($('#11').val()) + 1);
      let bm = $('#12').val();
      sign = 1;
      for (let i = 0; i < spmls.length; i++) {
        if ($('#12').val() === spmls[i]) {
          sign = 0;
          $('#xscpb').append('<tr><th>' + id + '</th><th>' + bm + '</th><th>' + $("#spml").find("tr").eq(i).find("th").eq(1).text() + '</th><th>'
            + $("#spml").find("tr").eq(i).find("th").eq(2).text() + '</th><th>'
            + $("#spml").find("tr").eq(i).find("th").eq(3).text() + '</th><th>'
            + $("#spml").find("tr").eq(i).find("th").eq(4).text() + '</th><th>'
            + $("#spml").find("tr").eq(i).find("th").eq(5).text() + '</th><th>10</tr><tr>');

          $('#kcz').find("tr").eq(i).find("th").eq(6).text(parseInt($('#kcz').find("tr").eq(i).find("th").eq(6).text()) + 10);
          $('#kcz').find("tr").eq(i).find("th").eq(8).text(parseInt($('#kcz').find("tr").eq(i).find("th").eq(8).text()) - 10);
          if (parseInt($('#kcz').find("tr").eq(i).find("th").eq(8).text()) < 20) alert("警告！超出下限！");

        }
      }
      if (sign === 1) alert("查无此商品。请不要继续下单")

    })
    $('#csjhcp').click(function () {
      let sign = 1;
      for (let i = 0; i < spmls.length; i++) {
        if ($('#2').val() === spmls[i]) {
          sign = 0;
          //修改库存账
          $("#kcz").find("tr").eq(i).find("th").eq(5).text(parseInt($("#kcz").find("tr").eq(i).find("th").eq(5).text()) + parseInt($("#8").val()));
          $("#kcz").find("tr").eq(i).find("th").eq(8).text(parseInt($("#kcz").find("tr").eq(i).find("th").eq(8).text()) + parseInt($("#8").val()));
          if (parseInt($("#kcz").find("tr").eq(i).find("th").eq(8).text()) > 1000) alert("警告！已经超出库存上限！")
        }
      }
      if (sign === 1) {
        spmls.push($('#2').val());
        $('#spml').append('<tr><th>' + $('#2').val() + '</th><th>' + $('#3').val() + '</th><th>' + $('#4').val() + '</th><th>' + $('#5').val() + '</th><th>' + $('#6').val() + '</th><th>' + (parseInt($('#7').val()) + 5) + '$' + '</th></tr>');
        $('#spjgb').append('<tr><th>' + $('#2').val() + '</th><th>' + $('#3').val() + '</th><th>' + $('#4').val() + '</th><th>' + $('#5').val() + '</th><th>' + $('#6').val() + '</th><th>' + (parseInt($('#7').val()) + 5) + '$' + '</th><th>' + (parseInt($('#7').val()) + 5) + '$' + '</th><th>大桔子</th></tr>');
        $('#kcz').append('<tr><th>' + $('#2').val() + '</th><th>' + $('#3').val() + '</th><th>' + $('#4').val() + '</th><th>' + $('#5').val() + '</th><th>' + $('#6').val() + '</th><th>' + (parseInt($('#8').val())) + '</th><th>0</th><th>' + (parseInt($('#7').val()) + 5) + '$' + '</th><th>' + $('#8').val() + '</th><th>20</th><th>1000</th></tr>');
      }

      let newjhcp = new jhcp($('#1').val(), $('#2').val(), $('#3').val(), $('#4').val(), $('#5').val(), $('#6').val(), $('#7').val(), $('#8').val());

      jhcps.push(newjhcp);
      $('#jhcdlb').append('<tr><th>' + $('#1').val() + '</th><th>' + $('#2').val() + '</th><th>' + $('#3').val() + '</th><th>' + $('#4').val() + '</th><th>' + $('#5').val() + '</th><th>' + $('#6').val() + '</th><th>' + $('#7').val() + '</th><th>' + $('#8').val() + '</th></tr>')
      console.log(jhcps)
      $('#1').val(parseInt($('#1').val()) + 1);
    });

    //商品目录
    function spml(spbm, pm, gg, cs, yxq, xsjg) {
      this.spbm = spbm;
      this.pm = pm;
      this.gg = gg;
      this.cs = cs;
      this.yxq = yxq;
      this.xsjg = xsjg;
    }
    //--------
    //库存子系统
    //库存账单
    function kcz(spbm, pm, gg, cs, yxq, jhl, jj, ckl, xsj, kcsl, kcxxl, kcsxl) {
      this.spbm = spbm;
      this.pm = pm;
      this.gg = gg;
      this.cs = cs;
      this.yxq = yxq;
      this.jhl = jhl;
      this.jj = jj;
      this.ckl = ckl;
      this.xsj = xsj;
      this.kcsl = kcsl;
      this.kcxxl = kcxxl;
      this.kcssl = kcsxl;
    }

    //-----
    //销售子系统
    //商品价格表
    function spjgb(spbm, pm, gg, cs, yxq, jyjg, xsjg, pzzrr) {
      this.spbm = spbm;
      this.pm = pm;
      this.gg = gg;
      this.cs = cs;
      this.yxq = yxq;
      this.jyjg = jyjg;
      this.xsjg = xsjg;
      this.pzzrr = pzzrr;
    }
    //销售传票
    function xscp(xscpbm, spbm, pm, gg, cs, yxq, xsj, xssl) {
      this.xscpbm = xscpbm;
      this.spbm = spbm;
      this.pm = pm;
      this.gg = gg;
      this.cs = cs;
      this.yxq = yxq;
      this.xsj = xsj;
      this.xssl = xssl;
    }

  </script>
</body>

</html>